#include <stdio.h>

int my_abs(int i)
{
	if (i < 0)
			return -i;
	else
			return i;
}

void main()
{

}


#if 0

/*
 * gcc
 */
	ARM平台没有负数运算指令，编译器使用了"零减去数值"的减法运算指令"Reverse Subtract"(减数和被减数位置对调的减法运算)，
	同样达到了替换符号的效果。
#endif

#if 0
/*
 * intel
 */
0000000000001129 <my_abs>:
    1129:	f3 0f 1e fa          	endbr64 
    112d:	55                   	push   %rbp
    112e:	48 89 e5             	mov    %rsp,%rbp
    1131:	89 7d fc             	mov    %edi,-0x4(%rbp)
    1134:	83 7d fc 00          	cmpl   $0x0,-0x4(%rbp)
    1138:	79 07                	jns    1141 <my_abs+0x18>
    113a:	8b 45 fc             	mov    -0x4(%rbp),%eax
    113d:	f7 d8                	neg    %eax
    113f:	eb 03                	jmp    1144 <my_abs+0x1b>
    1141:	8b 45 fc             	mov    -0x4(%rbp),%eax
    1144:	5d                   	pop    %rbp
    1145:	c3                   	retq   

0000000000001146 <main>:
    1146:	f3 0f 1e fa          	endbr64 
    114a:	55                   	push   %rbp
    114b:	48 89 e5             	mov    %rsp,%rbp
    114e:	90                   	nop
    114f:	5d                   	pop    %rbp
    1150:	c3                   	retq   
    1151:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
    1158:	00 00 00 
    115b:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)

/*
 * arm
 */
000000000040051c <my_abs>:
  40051c:	d10043ff 	sub	sp, sp, #0x10
  400520:	b9000fe0 	str	w0, [sp, #12]
  400524:	b9400fe0 	ldr	w0, [sp, #12]
  400528:	7100001f 	cmp	w0, #0x0
  40052c:	5400008a 	b.ge	40053c <my_abs+0x20>  // b.tcont
  400530:	b9400fe0 	ldr	w0, [sp, #12]
  400534:	4b0003e0 	neg	w0, w0
  400538:	14000002 	b	400540 <my_abs+0x24>
  40053c:	b9400fe0 	ldr	w0, [sp, #12]
  400540:	910043ff 	add	sp, sp, #0x10
  400544:	d65f03c0 	ret

0000000000400548 <main>:
  400548:	d503201f 	nop
  40054c:	d65f03c0 	ret


#endif

